group { name: "e/widgets/scrollframe";
   script {
      public loop_x, loop_y;

      public action_on_pos_vbar(val) {
         new x, y , w, h, x1, y1 , w1, h1;

         get_geometry(PART:"y_vbar_up", x, y, w, h);
         get_geometry(PART:"y_vbar_up_mapper", x1, y1, w1, h1);

         if (((y1 <= y) && (y <= (y1 + h1))) && (0 == get_int(loop_y))) {
//            set_state(PART:"arrow1_vbar", "hidden", 0.0);
//            set_state(PART:"sb_vbar_a1", "hidden", 0.0);
         } else {
//            set_state(PART:"arrow1_vbar", "default", 0.0);
//            set_state(PART:"sb_vbar_a1", "default", 0.0);
         }

        get_geometry(PART:"y_vbar_down", x,y,w, h);
        get_geometry(PART:"y_vbar_down_mapper", x1,y1,w1, h1);

         if (((y1 <= (y + h)) && ((y+ h) <= (y1 + h1))) && (0 == get_int(loop_y))) {
//            set_state(PART:"arrow2_vbar", "hidden", 0.0);
//            set_state(PART:"sb_vbar_a2", "hidden", 0.0);
         } else {
//            set_state(PART:"arrow2_vbar", "default", 0.0);
//            set_state(PART:"sb_vbar_a2", "default", 0.0);
         }

         if (val < 10)
            timer(0.1,"action_on_pos_vbar", val+1);
      }

      public action_on_pos_hbar(val) {
         new x, y , w, h, x1, y1 , w1, h1;

         get_geometry(PART:"x_hbar_left", x,y,w,h);
         get_geometry(PART:"x_hbar_left_mapper", x1,y1,w1, h1);

         if (((x1 <= x) && (x <= (x1 + w1))) && (0 == get_int(loop_x))) {
//            set_state(PART:"arrow1_hbar", "hidden", 0.0);
//            set_state(PART:"sb_hbar_a1", "hidden", 0.0);
         } else {
//            set_state(PART:"arrow1_hbar", "default", 0.0);
//            set_state(PART:"sb_hbar_a1", "default", 0.0);
         }

         get_geometry(PART:"x_hbar_right", x,y,w, h);
         get_geometry(PART:"x_hbar_right_mapper", x1,y1,w1, h1);

         if (((x1 <= (x + w)) && ((x + w) <= (x1 + w1))) && (0 == get_int(loop_x))) {
//            set_state(PART:"arrow2_hbar", "hidden", 0.0);
//            set_state(PART:"sb_hbar_a2", "hidden", 0.0);
         } else {
//            set_state(PART:"arrow2_hbar", "default", 0.0);
//            set_state(PART:"sb_hbar_a2", "default", 0.0);
         }

         if (val < 10)
            timer(0.1,"action_on_pos_hbar", val+1);
      }
   }

   parts {
      //////////////////////////////////////////////////////////////////////
      part { name: "bg"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "e.swallow.content";
            color_class: "/bg/normal/scroller/base";
         }
      }
      part { name: "clipper"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "e.swallow.content";
         }
      }
      part { name: "e.swallow.content"; type: SWALLOW;
         clip_to: "clipper";
         description { state: "default" 0.0;
         }
      }

      //////////////////////////////////////////////////////////////////////

// vert bar ////////////////////////////////////////////////////////////////
      part { name: "sb_vbar_show"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "sb_vbar"; type: RECT;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            min: 15 1;
            align: 1.0 0.0;
            rel1.relative: 1.0 0.0;
            rel1.offset: -1 0;
            rel2.relative: 1.0 0.0;
            rel2.to_y: "sb_hbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 999999;
         }
      }
      part { name: "sb_vbar_p1"; type: RECT;
         clip_to: "sb_vbar";
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.to: "sb_vbar";
            rel2.relative: 1.0 0.0;
            rel2.to: "e.dragable.vbar";
            fixed: 1 1;
         }
      }
      part { name: "sb_vbar_p2"; type: RECT;
         clip_to: "sb_vbar";
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.relative: 0.0 1.0;
            rel1.to: "e.dragable.vbar";
            rel2.to: "sb_vbar";
            fixed: 1 1;
         }
      }
      part { name: "e.dragable.vbar"; type: RECT;
         clip_to: "sb_vbar";
         scale: 1;
         dragable.x: 0 0 0;
         dragable.y: 1 1 0;
         dragable.confine: "sb_vbar";
         description { state: "default" 0.0;
            fixed: 1 1;
            min: 15 15;
            rel1.relative: 0.5  0.5;
            rel1.to: "sb_vbar";
            rel2.relative: 0.5  0.5;
            rel2.to: "sb_vbar";
            color: 0 0 0 0; // no cc
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
         }
      }
      part { name: "sb_vbar_over"; type: RECT;
         repeat_events: 1;
         scale: 1;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.to: "sb_vbar";
            rel1.offset: -45 0;
            rel2.to: "sb_vbar";
            fixed: 1 1;
            offscale;
         }
      }
      program { signal: "mouse,in"; source: "sb_vbar_over";
         action: STATE_SET "over" 0.0;
         transition: DECELERATE 0.2 USE_DURATION_FACTOR 1;
         target: "base_vbar";
      }
      program { signal: "mouse,out"; source: "sb_vbar_over";
         action: STATE_SET "default" 0.0;
         transition: DECELERATE 0.2 USE_DURATION_FACTOR 1;
         target: "base_vbar";
      }
      part { name: "y_vbar_up_mapper"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 4 2;
            max: 4 2;
            fixed: 1 1;
            align: 0.0 0.0;
            rel1.to: "sb_vbar";
            rel2.to: "sb_vbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "y_vbar_up"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 4 2;
            max: 4 2;
            fixed: 1 1;
            align: 0.0 0.0;
            rel1.to: "e.dragable.vbar";
            rel2.to: "e.dragable.vbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "y_vbar_down_mapper"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 4 2;
            max: 4 2;
            fixed: 1 1;
            align: 0.0 1.0;
            rel1.to: "sb_vbar";
            rel2.to: "sb_vbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "y_vbar_down"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 4 2;
            max: 4 2;
            fixed: 1 1;
            align: 0.0 1.0;
            rel1.to: "e.dragable.vbar";
            rel2.to: "e.dragable.vbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      program {
         signal: "e,action,show,vbar"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "sb_vbar";
         target: "sb_vbar_show";
         target: "e.dragable.vbar";
         target: "y_vbar_up_mapper";
         target: "y_vbar_up";
         target: "y_vbar_down_mapper";
         target: "y_vbar_down";
         after: "check_pos_vbar";
      }
      program {
         signal: "e,action,hide,vbar"; source: "e";
         action: STATE_SET "hidden" 0.0;
         target: "sb_vbar";
         target: "sb_vbar_show";
         target: "e.dragable.vbar";
         target: "y_vbar_up_mapper";
         target: "y_vbar_up";
         target: "y_vbar_down_mapper";
         target: "y_vbar_down";
      }
      program {
         signal: "mouse,down,1*"; source: "sb_vbar_p1";
         action: DRAG_VAL_PAGE 0.0 -1.0;
         target: "e.dragable.vbar";
      }
      program {
         signal: "mouse,down,1*"; source: "sb_vbar_p2";
         action: DRAG_VAL_PAGE  0.0 1.0;
         target: "e.dragable.vbar";
      }
      program { name: "check_pos_vbar";
         script {
            action_on_pos_vbar(10);
         }
      }

// horiz bar /////////////////////////////////////////////////////////////
      part { name: "sb_hbar_show"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "sb_hbar"; type: RECT; mouse_events: 0;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            min: 1 15;
            align: 0.0 1.0;
            rel1.relative: 0.0 1.0;
            rel1.offset: 0 -1;
            rel2.relative: 0.0 1.0;
            rel2.to_x: "sb_vbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 999999 0;
         }
      }
      part { name: "sb_hbar_p1"; type: RECT;
         clip_to: "sb_hbar";
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.to: "sb_hbar";
            rel2.relative: 0.0 1.0;
            rel2.to: "e.dragable.hbar";
            fixed: 1 1;
         }
      }
      part { name: "sb_hbar_p2"; type: RECT;
         clip_to: "sb_hbar";
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.relative: 1.0 0.0;
            rel1.to: "e.dragable.hbar";
            rel2.to: "sb_hbar";
            fixed: 1 1;
         }
      }
      part { name: "e.dragable.hbar"; type: RECT;
         scale: 1;
         clip_to: "sb_hbar";
         dragable.x: 1 1 0;
         dragable.y: 0 0 0;
         dragable.confine: "sb_hbar";
         description { state: "default" 0.0;
            fixed: 1 1;
            min: 15 15;
            rel1.relative: 0.5  0.5;
            rel1.to: "sb_hbar";
            rel2.relative: 0.5  0.5;
            rel2.to: "sb_hbar";
            color: 0 0 0 0; // no cc
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
         }
      }
      part { name: "sb_hbar_over"; type: RECT;
         repeat_events: 1;
         scale: 1;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
            rel1.to: "sb_hbar";
            rel1.offset: 0 -45;
            rel2.to: "sb_hbar";
            fixed: 1 1;
            offscale;
         }
      }
      program { signal: "mouse,in"; source: "sb_hbar_over";
         action: STATE_SET "over" 0.0;
         transition: DECELERATE 0.2 USE_DURATION_FACTOR 1;
         target: "base_hbar";
      }
      program { signal: "mouse,out"; source: "sb_hbar_over";
         action: STATE_SET "default" 0.0;
         transition: DECELERATE 0.2 USE_DURATION_FACTOR 1;
         target: "base_hbar";
      }
      part { name: "x_hbar_left_mapper"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 2 4;
            max: 2 4;
            fixed: 1 1;
            align: 0.0 1.0;
            rel1.to: "sb_hbar";
            rel2.to: "sb_hbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "x_hbar_left"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 2 4;
            max: 2 4;
            fixed: 1 1;
            align: 0.0 1.0;
            rel1.to: "e.dragable.hbar";
            rel2.to: "e.dragable.hbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "x_hbar_right_mapper"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 2 4;
            max: 2 4;
            fixed: 1 1;
            align: 1.0 1.0;
            rel1.to: "sb_hbar";
            rel2.to: "sb_hbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      part { name: "x_hbar_right"; type: SPACER;
         scale: 1;
         repeat_events: 1;
         description { state: "default" 0.0;
            min: 2 4;
            max: 2 4;
            fixed: 1 1;
            align: 1.0 1.0;
            rel1.to: "e.dragable.hbar";
            rel2.to: "e.dragable.hbar";
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            min: 0 0;
            max: 0 0;
         }
      }
      program {
         signal: "e,action,show,hbar"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "sb_hbar";
         target: "sb_hbar_show";
         target: "e.dragable.hbar";
         target: "x_hbar_left_mapper";
         target: "x_hbar_left";
         target: "x_hbar_right_mapper";
         target: "x_hbar_right";
         after: "check_pos_hbar";
      }
      program {
         signal: "e,action,hide,hbar"; source: "e";
         action: STATE_SET "hidden" 0.0;
         target: "sb_hbar";
         target: "sb_hbar_show";
         target: "e.dragable.hbar";
         target: "x_hbar_left_mapper";
         target: "x_hbar_left";
         target: "x_hbar_right_mapper";
         target: "x_hbar_right";
      }
      program {
         signal: "mouse,down,1*"; source: "sb_hbar_p1";
         action: DRAG_VAL_PAGE -1.0 0.0;
         target: "e.dragable.hbar";
         after: "check_pos_hbar";
      }
      program {
         signal: "mouse,down,1*"; source: "sb_hbar_p2";
         action: DRAG_VAL_PAGE  1.0 0.0;
         target: "e.dragable.hbar";
         after: "check_pos_hbar";
      }
      program { name: "check_pos_hbar";
         script {
            action_on_pos_hbar(10);
         }
      }

      //////////////////////////////////////////////////////////////////////
      part { name: "color_vbar"; type: RECT; mouse_events: 0;
         clip_to: "sb_vbar_show";
         description { state: "default" 0.0;
            fixed: 1 1;
            color_class: "/fg/normal/scroller/bar/horizontal";
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/scroller/bar/horizontal";
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/scroller/bar/horizontal";
         }
      }

      part { name: "base_vbar"; type: RECT; mouse_events: 0;
         scale: 1;
         clip_to: "color_vbar";
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "e.dragable.vbar";
            min: 5 15;
            max: 5 999999;
            align: 1.0 0.5;
         }
         description { state: "over" 0.0;
            inherit: "default" 0.0;
            min: 15 15;
            max: 15 999999;
         }
      }

      //////////////////////////////////////////////////////////////////////
      part { name: "color_hbar"; type: RECT; mouse_events: 0;
         clip_to: "sb_hbar_show";
         description { state: "default" 0.0;
            fixed: 1 1;
            color_class: "/fg/normal/scroller/bar/horizontal";
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/scroller/bar/horizontal";
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/scroller/bar/horizontal";
         }
      }

      part { name: "base_hbar"; type: RECT; mouse_events: 0;
         scale: 1;
         clip_to: "color_hbar";
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "e.dragable.hbar";
            min: 15 5;
            max: 999999 5;
            align: 0.5 1.0;
         }
         description { state: "over" 0.0;
            inherit: "default" 0.0;
            min: 15 15;
            max: 999999 15;
         }
      }
   }
   programs {
      program { signal: "mouse,down,1*"; source: "e.dragable.vbar";
         action: STATE_SET "clicked" 0.0;
         target: "e.dragable.vbar";
         target: "color_vbar";
      }
      program { signal: "mouse,down,*"; source: "e.dragable.vbar";
         action: SIGNAL_EMIT "e,vbar,press" "e";
      }
      program { signal: "mouse,up,1"; source: "e.dragable.vbar";
         action: STATE_SET "default" 0.0;
         target: "e.dragable.vbar";
         target: "color_vbar";
      }
      program { signal: "mouse,up,*"; source: "e.dragable.vbar";
         action: SIGNAL_EMIT "e,vbar,unpress" "e";
      }

      program { signal: "mouse,down,1*"; source: "e.dragable.hbar";
         action: STATE_SET "clicked" 0.0;
         target: "e.dragable.hbar";
         target: "color_hbar";
      }
      program { signal: "mouse,down,*"; source: "e.dragable.hbar";
         action: SIGNAL_EMIT "e,hbar,press" "e";
      }
      program { signal: "mouse,up,1"; source: "e.dragable.hbar";
         action: STATE_SET "default" 0.0;
         target: "e.dragable.hbar";
         target: "color_hbar";
      }
      program { signal: "mouse,up,*"; source: "e.dragable.hbar";
         action: SIGNAL_EMIT "e,hbar,unpress" "e";
      }
   }
}
